<!--4.15-->
<template>
  <router-view v-if="isRouterAlive"></router-view>
</template>


<script>
import axios from 'axios'
export default {
  name: 'App',
  provide() {
    return {
      reload: this.reload
    }
  },
  data() {
    return {
      isRouterAlive: true,
      //默认用户
      default_user: {
        code: 200,
        message: null,
        data: {
          userInfo: {
            id: 11,
            username: 'wbw',
            phone: "13081860369",
            email: "2814866235@qq.com",
            citizenId: "430512198908131367",
            pocket: "net1024:aaj1hxrgczugmycf1apwkznsc2cvpzgwky8hcp8tx8",
            avatar: 'default.jpg',
            isAdmin: null,
            isCertified: 1,
            realName: "武博文",
            tag1: "摄影",
            tag2: null,
            tag3: null,
            front: "正.jpg",
            negative: "反.jpg"
          },
           // token: "eyJ0eXBlIjoiSldUIiwiYWxnIjoiSFM1MTIifQ.eyJzdWIiOiJ3YnciLCJpYXQiOjE2ODA2Njk4NzMsImV4cCI6MTY4MTI3NDY3M30.GkNP2KaMcwOA98_62AHW6oLmNXPimDVZJaoHuR9AtjMILDAD5-W_HW1cdmlX0o-0R1Dkx8ExKh-vi1sF1Jmb5Q"
        }
      },
    }
  },
  created() {
    // TODO 添加一个公用的游客账户 id是11 在所有设计到写的地方加上检查，如果id是11，则报错未登录
    if (sessionStorage.getItem("userObj") == null) {
      sessionStorage.setItem("userObj", JSON.stringify(this.default_user.data.userInfo))
      // sessionStorage.setItem("token", JSON.stringify(this.default_user.data.token))
      axios.get('http://120.48.51.66:8081/user/login',{
        params:{
          username:'wbw',
          password:'123456'
        }
      }).then((response) => {
        if (response.data.code == 200){
          //sessionStorage.setItem("userObj", JSON.stringify(response.data.data.userInfo))
          sessionStorage.setItem("token", JSON.stringify(response.data.data.token))
          this.reload()
        }
      })
    }
  },
  methods: {
    reload() {
      this.isRouterAlive = false,
          this.$nextTick(function () {
                this.isRouterAlive = true;
              }
          )
    }
  }


}
</script>

<style>

.el-header {
  background-color: #ffffff;
}

.el-main {
}

/* 隐藏滚动条 */
::-webkit-scrollbar {
  display: none;
}

body {
  /*  background-image: url('@/assets/logo.png');

    background-size: 6rem 6rem;
    background-position: 2.75rem 2.75rem, 2.5rem 2rem, 2.5rem 2.5rem;*/
  backdrop-filter: blur(0px);
}


</style>
